package com.qs.education.bean.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;

/**
 * @class EducationTeacher
 * @author Leon
 * @description
 * @date Nov 5, 2018
 */
@Entity
@Table(name = "education_teacher")
@Getter
@Setter
public class EducationTeacher {

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;
	private String headImage;
	private String name;
	private String mobile;
	private String password;
	
	private String createTime;
	@Column(name = "token")
	private String teacherToken;

	@OneToMany
	@JoinColumn(name = "teacher_id")
	@JsonIgnoreProperties(value = { "teachers", "students", "teacher", "grade", "clazz", "createTime" ,"homeWorkList" })
	private List<EducationGroup> group;

	@ManyToOne
	@JoinColumn(name = "school_id")
	@JsonIgnoreProperties(value = { "students", "teachers" })
	private EducationSchool school;

	@ManyToOne
	@JoinColumn(name = "subject_id", referencedColumnName = "id")
	private EducationSubject subject;


	@ManyToMany
	@JoinTable(name = "education_teacher_group", joinColumns = {
			@JoinColumn(name = "teacher_id", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "group_id", referencedColumnName = "id") })

	@JsonIgnoreProperties(value = { "teachers", "students", "teacher", "grade", "clazz", "homeWorkList" })
	private List<EducationGroup> groups;

	@OneToMany
	@JoinColumn(name = "teacher_id")
	@JsonIgnoreProperties(value = { "group", "teacher" })
	private List<EducationHomeWork> homeWorkList;
	
	@OneToMany
	@JoinColumn(name = "teacher_id")
	@JsonIgnoreProperties(value = { "group", "teacher" })
	private List<EducationTeacherMessage> messages;
	
}
